# import seaborn as sns
# import matplotlib.pyplot as plt
# import numpy as np
#
# # 示例数据
# data = np.array([[37, 0, 0, 0, 0, 0, 0],
#                  [0, 75, 0, 0, 0, 0, 0],
#                  [0, 0, 30, 49, 12, 0, 0],
#                  [0, 0, 0, 130, 0, 0, 0],
#                  [0, 0, 0, 0, 126, 0, 0],
#                  [0, 0, 0, 0, 0, 42, 0],
#                  [0, 0, 0, 0, 0, 0, 82]])
#
# # 设置背景颜色
# fig, ax = plt.subplots()
# fig.patch.set_facecolor('lightgrey')  # 设置背景颜色
# sns.heatmap(data, annot=True, fmt="d", cmap="magma", ax=ax)
#
# plt.show()



import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np

# 示例数据
data = np.array([[37, 0, 0, 0, 0, 0, 0],
                 [0, 75, 0, 0, 0, 0, 0],
                 [0, 0, 30, 49, 12, 0, 0],
                 [0, 0, 0, 130, 0, 0, 0],
                 [0, 0, 0, 0, 126, 0, 0],
                 [0, 0, 0, 0, 0, 42, 0],
                 [0, 0, 0, 0, 0, 0, 82]])

# 创建热力图
fig, ax = plt.subplots()
sns.heatmap(data, annot=True, fmt="d", cmap="YlGnBu", ax=ax)

# 设置背景颜色
fig.patch.set_facecolor('white')  # 设置背景颜色为白色

# 设置标签和标题
ax.set_xlabel('Predicted labels')
ax.set_ylabel('True labels')
ax.set_title('Confusion Matrix')

plt.show()